<?php

// $Id$


require_once($WSC->get_site_inc_dir().'modules/admin_panel/site_admin_ajax_grid_ctrl_ua.class.php');
require_once('ci_nom_select_grid_ctrl.class.php');


class CI_Nom_Select_Grid_Ajax_Ctrl extends Site_Admin_Ajax_Grid_Ctrl_UA {
	protected function init_transit_vars() {
		$this->add_transit_var('nom');
		$this->add_transit_var('ret');
		$this->add_transit_var('ci');
		$this->add_transit_var('ciat');
	}


	protected function create_grid_ctrl() {
		$ciat_id = $this->get_transit_var('ciat');
		$ci_id = $this->get_transit_var('ci');

		$nom_hid = $this->get_transit_var('nom');
		$nomenclature = new TCMS_Nomenclature_DBC();

		$dbc = $this->get_dbc();
		if (!$nomenclature->load_by_hid($dbc, $nom_hid)) {
			throw new Tangra_Module_Exception('Cannot find nomenclature with hid = '.$nom_hid);
		}


		$tvm = $this->get_tvm();
		$ret = new CI_Nom_select_Grid_Ctrl('ci_nom_select', $tvm, Tangra_Parameter_Method::GET, $nomenclature->get_id(), $ci_id, $ciat_id);

		return $ret;
	}
}